# cmake_minimum_required(VERSION 3.10)
# project(redis_app)

# # 设置C++标准为C++17
# set(CMAKE_CXX_STANDARD 17)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)

# # 添加可执行文件
# add_executable(redis redis.cc)

# # 链接线程库
# target_link_libraries(redis PRIVATE pthread)

# # 链接hiredis静态库
# # /usr/lib/x86_64-linux-gnu/libhiredis.a
# target_link_libraries(redis PRIVATE hiredis)

# # 链接redis++静态库
# # /usr/local/lib/libredis++.a
# target_link_libraries(redis PRIVATE redis++)

# # 添加可执行文件
# add_executable(string string.cc)

# # 链接线程库
# target_link_libraries(string PRIVATE pthread hiredis redis++)

# # 添加可执行文件
# add_executable(list list.cc)

# # 链接线程库
# target_link_libraries(list PRIVATE pthread hiredis redis++)

cmake_minimum_required(VERSION 3.10)
project(redis_app)

# 设置C++标准（统一配置一次）
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(EXECUTABLES
    redis 
    list   
    string 
    set
    zset
)

# 定义公共依赖库（所有目标共享的库，统一管理）
set(COMMON_LIBS PRIVATE pthread hiredis redis++)

foreach(target IN LISTS EXECUTABLES)
    add_executable(${target} ${target}.cc)
    target_link_libraries(${target} ${COMMON_LIBS})
endforeach()

